//
//  AXHdzqZqgCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/31.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqZqgCell.h"

@interface AXHdzqZqgCell ()

@end


@implementation AXHdzqZqgCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
      
    }
    return self;
}


- (void)creatView {
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    /** 图片比例切 */
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    self.productImageView.image = [UIImage imageNamed:@"tz.jpeg"];
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.text = @"优选水蜜桃";
    self.productNameLabel.textColor =COLOR_DIV ;
    self.productNameLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.productNameLabel];
    /** 自营 */
    self.selfLabel = [[UILabel alloc]init];
    self.selfLabel.text = @"自营";
    self.selfLabel.backgroundColor = COLOR_GREEN;
    self.selfLabel.textColor = [UIColor whiteColor];
    self.selfLabel.font = [UIFont systemFontOfSize:10];;
    [self.contentView addSubview:self.selfLabel];
    /** 新价格 */
    self.nowPriceLabel = [[UILabel alloc]init];
    self.nowPriceLabel.text = @"￥98.00";
    self.nowPriceLabel.font = FONT_FOURTEEN;;
    self.nowPriceLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.nowPriceLabel];

    /** 立即拼团*/
    self.shopCartButton = [[UIButton alloc]init];
    self.shopCartButton.cornerRadius = 5;
    self.shopCartButton.backgroundColor = COLOR_ORG;
    [self.shopCartButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.shopCartButton setTitle:@"立即拼团" forState:UIControlStateNormal];
    [self.contentView addSubview:self.shopCartButton];
    
    
    
}

- (void)setlayout {
    
    /** 购物车*/
    self.shopCartButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(30);
    
    /** 自营 */
    self.selfLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(40)
    .heightIs(20);
    
    /** 产品图片 */
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.selfLabel, 5)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topEqualToView(self.productImageView)
    .widthIs(100)
    .autoHeightRatio(0)
    .minHeightIs(40);
    
    
    /** 新价格 */
    self.nowPriceLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .topSpaceToView(self.productNameLabel, 10)
    .widthIs(100)
    .heightIs(20);
    
    //cell 自适应第一步
    [self setupAutoHeightWithBottomView:self.productImageView bottomMargin:10];
    
}


- (void)setModel:(AXHdzqZqgModel *)model {
    
    _model = model;

    [self.productImageView sd_setImageWithURL:[NSURL URLWithString:_model.cycleBuyLogo] placeholderImage:[UIImage imageNamed:@"placeHold"]];
    self.productNameLabel.text = _model.cycleBuyName;
    self.nowPriceLabel.text = _model.goodsTotalPrice;
    self.selfLabel.text = _model.shopType;
    [self setlayout];
    
    [self setlayout];
    
}


@end
